package
{
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	public class AstarNode implements ISearchNode, ISpatialIndexable
	{
		public var parent:AstarNode;
		public var f:Number; // weight from current position to this node
		public var g:Number; // weight from this node to final destination
		
		private var m_rectangle:Rectangle;
		
		public function AstarNode()
		{
			m_rectangle = new Rectangle;
		}
		
		public function getRect():Rectangle{
			return m_rectangle;
		}
		
		public function set location(pnt:Point):void{
			m_rectangle.x = pnt.x;
			m_rectangle.y = pnt.y;
		}
		
		public function get location():Point{
			return m_rectangle.topLeft;
		}
		
		public function get h():Number{
			return f + g;
		}
		
		public function getDebugImage(color:uint):Sprite{
			var spr:Sprite = Util.getRect(Global.PPU, Global.PPU, color);
			spr.x = location.x * Global.PPU;
			spr.y = location.y * Global.PPU;
			return spr;
		}
		
		public function getValue():Number{
			return h;
		}
	}
}